package com.itheima.web.controller.stat;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.stat.StatService;
import com.itheima.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat/")
public class StatController extends BaseController {

    @Reference
    private StatService statService;

    @RequestMapping(value = "/toCharts", name = "跳转图形展示页面")
    public String toCharts(String chartsType) {

        return "/stat/stat-" + chartsType;
    }


    @RequestMapping(value = "/factoryCharts", name = "查询厂家销售统计数据")
    @ResponseBody
    public List<Map> factoryCharts() {
        return statService.findFactoryCharts(getCompanyId());
    }

    @RequestMapping(value = "/sellCharts", name = "查询产品的销量排行榜数据")
    @ResponseBody
    public List<Map> sellCharts() {
        return statService.findSellCharts(getCompanyId());
    }


    @RequestMapping(value = "/onlineCharts", name = "查询系统在线压力数据")
    @ResponseBody
    public List<Map> onlineCharts() {
        return statService.findOnlineCharts(getCompanyId());
    }

    @RequestMapping(value = "/deptCharts", name = "查询部门人数数据")
    @ResponseBody
    public List<List> deptCharts() {
        return statService.findDeptCharts(getCompanyId());
    }

    @RequestMapping(value = "/contractCharts", name = "查询购销合同签订数据")
    @ResponseBody
    public List<Map> contractCharts() {
        return statService.findContractCharts(getCompanyId());
    }

    @RequestMapping(value = "/marketpriceCharts", name = "查询产品市场价数据")
    @ResponseBody
    public List<Map> marketpriceCharts() {
        return statService.findMarketpriceCharts(getCompanyId());
    }

}
